﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Strive.DataAccess;
using OTA.Notification.Interface.IBO.Dictionary;
using OTA.Notification.Interface.IDAO.Dictionary;
using OTA.Notification.Entity.Dictionary;
using OTA.Notification.DAO.Dictionary;
using Strive.DataAccess.Base.Model.PageObject;
using Strive.DataAccess.Base.Model.SearcherObject;
using OTA.Notification.Common;
using Strive.Util.Text;

namespace OTA.Notification.BO.Dictionary
{
    
    public class DictionaryBO:BaseBOBean<int,OTA_DICTIONARY,DictionaryDao,IDictionaryDao>,IDictionaryBo
    {


        #region IDictionaryBo 成员

        /// <summary>
        /// 获得一条信息
        /// </summary>
        /// <param name="_id"></param>
        /// <returns></returns>
        public OTA_DICTIONARY getDictionary(int _id)
        {
            return base.DomainDAO.getDictionary(_id);
        }

        /// <summary>
        /// 获得一条信息
        /// </summary>
        /// <param name="_type">类型</param>
        /// <param name="_code">编码</param>
        /// <param name="_value">值</param>
        /// <returns></returns>
        public OTA_DICTIONARY getDictionary(DicType type, string _code, string _value)
        {
            string _type = StringHelper.EnumToString(type);

            return base.DomainDAO.getDictionary(_type, _code, _value);
        }

        public OTA_DICTIONARY getDictionary(string type, string _pcode, string _value)
        {
            return base.DomainDAO.getDictionary(type, _pcode, _value);
        }

        /// <summary>
        /// 获得一个值得描述信息
        /// </summary>
        /// <param name="_type">类型</param>
        /// <param name="_code">编码</param>
        /// <param name="_value">值</param>
        /// <param name="_languagetype">语言</param>
        /// <returns></returns>
        public string getName(DicType type, string _code, string _value, LanguageType languagetype)
        {
            string _type = StringHelper.EnumToString(type);
            string _languagetype = StringHelper.EnumToString(languagetype);
            return base.DomainDAO.getName(_type, _code, _value, _languagetype);
        }

        /// <summary>
        /// 查询 一个code单元的信息
        /// </summary>
        /// <param name="_code">编码</param>
        /// <param name="_type">类型</param>
        /// <param name="_languagetype">语言 en-us\zh-cn</param>
        /// <returns></returns>
        public IList<OTA_DICTIONARY> getAllDictionary(string _code, DicType type, LanguageType languagetype)
        {
            string _type = StringHelper.EnumToString(type);
            string _languagetype = StringHelper.EnumToString(languagetype);

            return base.DomainDAO.getAllDictionary(_code, _type, _languagetype);
        }

        public IList<OTA_DICTIONARY> getAllDictionary(string code, string type, LanguageType languagetype)
        {
            string _languagetype = StringHelper.EnumToString(languagetype);
            return base.DomainDAO.getAllDictionary(code, type, _languagetype);
        }

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="pageObject"></param>
        /// <returns></returns>
        public PageResult<OTA_DICTIONARY> getDictionaryPageList(BasePageSearch pageObject)
        {
            return base.DomainDAO.getDictionaryPageList(pageObject);
        }



        public bool insertDictionary(OTA_DICTIONARY _dict)
        {
            OTA_DICTIONARY havedict = getDictionary(_dict.TYPE, _dict.PARENT_CODE, _dict.VALUE.ToString());
            if (havedict != null)
                return false;
            return base.DomainDAO.insertDictionary(_dict);
        }

        public bool updateDictionary(OTA_DICTIONARY _dict)
        {
            OTA_DICTIONARY havedict = base.DomainDAO.getDictionary(_dict.TYPE, _dict.PARENT_CODE, _dict.VALUE.ToString(), _dict.ID.ToString());
            if (havedict != null)
                return false;
            return base.DomainDAO.updateDictionary(_dict);
        }



        public bool deleteDictionary(int _id)
        {
            return base.DomainDAO.deleteDictionary(_id);
        }

        #endregion

        protected override void ValidationRules()
        {
            throw new NotImplementedException();
        }



        #region IDictionaryBo 成员


        public string clearBadtree()
        {
            return base.DomainDAO.clearBadtree();
        }

        #endregion
    }
}
